package cn.go.buster.launcher.api;

import android.os.Handler;
import android.os.Looper;

/**
 * @author logcat
 * @date 2020/07/20 16:08
 * 事件发送类的基类
 */
public class Poster implements IPoster {
    protected  Handler handler;
    protected  Handler mainThreadHandler;
    protected  Runnable currentRunnable;

    protected static volatile Poster instance;

    protected Poster(){

    }


    public static Poster get(){
        if(instance == null){
            synchronized (IPoster.class){
                if(instance == null){
                    instance = new Poster();
                }
            }
        }

        return instance;
    }

    public void setCurrentRunnable(Runnable currentRunnable) {
        this.currentRunnable = currentRunnable;
    }

    protected Handler getHandler() {
        if(handler == null){
            synchronized (Handler.class){
                if(handler == null){
                    handler = new Handler();
                }
            }
        }
        return handler;
    }


    protected Handler getMainThreadHandler() {
        if(mainThreadHandler == null){
            synchronized (Handler.class){
                if(mainThreadHandler == null){
                    mainThreadHandler = new Handler(Looper.getMainLooper());
                }
            }
        }
        return mainThreadHandler;
    }


    @Override
    public void register(Object obj) {

    }

    @Override
    public void unRegister(Object obj) {

    }

    @Override
    public void post(String tag) {

    }

    @Override
    public void post(String tag, Object... params) {

    }
}
